Skip to content

Fix MageCookies.getAll() throwing on non-JSON cookies (e.g. Adobe s_sq)#2

Open
Maksold wants to merge 1 commit into
LokiExtensions:masterfrom
Maksold:fix/cookies-json-guard
Open

Fix MageCookies.getAll() throwing on non-JSON cookies (e.g. Adobe s_sq)#2
Maksold wants to merge 1 commit into
LokiExtensions:masterfrom
Maksold:fix/cookies-json-guard

Conversation

@Maksold

@Maksold Maksold commented Jul 22, 2026

Copy link
Copy Markdown

MageCookies.getAll() runs JSON.parse() on any cookie whose value starts with [ or {, unguarded. A value that looks like JSON but isn't throws a SyntaxError.

Real-world trigger: Adobe Analytics' ActivityMap cookie s_sq, whose empty-state value is [[B]]. getAll() throws before returning any key, so every consumer dies at once — get('form_key') in ajax-queue.phtml and polling.phtml, plus mage-messages and section_data_ids. Net effect: the whole AJAX layer (grid search/sort/filter, form save, polling) silently stops for that visitor, on frontend and adminhtml alike.

Fix: wrap the parse in try/catch and fall back to the raw string. JSON cookies Loki set still round-trip; foreign cookies no longer abort the request.

Repro: document.cookie = 's_sq=%5B%5BB%5D%5D', open any Loki grid, sort → Uncaught SyntaxError: "[[B]]" is not valid JSON.

FYI: [[B]] is s_sq's documented null value (ActivityMap with trackInlineStats=false) — ref.

JSON.parse() ran on any cookie starting with [ or {, so a foreign
cookie that only looks like JSON (e.g. Adobe Analytics s_sq="[[B]]")
threw a SyntaxError and aborted every caller of getAll()/get().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant